﻿using Abp.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using SOEI.Solution.DomainEntities.Parameters.DomainService;
using SOEI.Solution.DomainEntities.Parameters.Dtos;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace SOEI.Solution.DomainEntities.Currency
{
    /// <summary>
    /// 【扩展模块】  <br/>
    /// 【功能描述】  ：项目公共服务<br/>
    /// 【创建日期】  ：2020.05.21 <br/>
    /// 【开发人员】  ：static残影<br/>
    ///</summary>
    [AbpAuthorize()]
    [ApiExplorerSettings(GroupName = "Manager", IgnoreApi = false)]
    public class CurrencyAppService : SolutionAppServiceBase, ICurrencyAppService
    {
        /// <summary>
        /// 【Parameter】参数的领域服务
        /// </summary>
        private readonly IParameterManager _parameterManager;


        public CurrencyAppService(
            IParameterManager parameterManager
        )
        {
            _parameterManager = parameterManager;
        }

        /// <summary>
        ///【公共服务】 获取所有机构人员类型参数
        /// </summary>
        /// <returns></returns>
        public async Task<ICollection<ParameterListDto>> GetPersonTypeData()
        {
            // 编辑时候选择的下拉框人员类型
            var query = this._parameterManager.QueryPersonType();
            var personTypeList = await query
                .AsNoTracking()
                .ToListAsync();
            return ObjectMapper.Map<ICollection<ParameterListDto>>(personTypeList);
        }

        /// <summary>【公共服务】获取监管协议状态数据
        /// </summary>
        /// <returns></returns>
        public async Task<ICollection<ParameterListDto>> GetAgreementStateData()
        {
            var query = this._parameterManager.QueryAgreementState();

            var list = await query.AsNoTracking().ToListAsync();

            return ObjectMapper.Map<ICollection<ParameterListDto>>(list);
        }
    }
}
